import { useRef } from 'react'

const useFetch = axios => {
    const http = useRef({
        async get({
            url,
            params = {}
        }) {
            try {
                let result = await axios.get(url,{
                    params
                })
                return result.data
            }
            catch(err) {
                return err
            }
        }
    })

    return http
}

export default useFetch